<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>

    <script type="text/javascript" charset="utf-8" src="/editor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/editor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/editor/lang/zh-cn/zh-cn.js"></script>




<style type="text/css">
  .myhidden{display:none}
</style>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-type" data-rule="required" style="
    display: block!important;
"  class="form-control selectpicker" name="row[type]">
                {foreach name="typeList" item="vo"}
                    <option value="{$key}" {in name="key" value="preson"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>
			{literal}
			<script type="text/javascript">
			 　$('#c-type').change(function(){  
			 
					 if($(this).val()=='person'){
					 　$('#myidcustomer').toggle();
					  
					 }else{
					 　$('#myidcustomer').toggle();
					  $('#myidcustomer input').val('无');
					 }
			　
				})  
			{/literal}
			</script>
        </div>
    </div>
    <div class="form-group"  id= 'myidcustomer'>
        <label class="control-label col-xs-12 col-sm-2">{:__('Id_customer')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-id_customer"  class="form-control" name="row[id_customer]" type="text">
        </div>
		<span style="color:red">通知类型为个人 则必填</span>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Msg_type')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-msg_type"  class="form-control" name="row[msg_type]" type="text">
        </div>
		
		
    </div>
	<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">个人消息类型:</label>
        <div class="col-xs-12 col-sm-8">
         <span style="color:red ">注册通知</span>
		 |<span style="color:red ">购物车通知</span>
		 |<span style="color:red ">VIP升级提示</span>
		 |<span style="color:red ">订单生成通知</span><br>
		 |<span style="color:red ">订单备货通知</span>
		 |<span style="color:red ">订单发货通知</span>
		 |<span style="color:red ">订单物流通知</span>
        </div>
    </div>
	<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">全站消息类型:</label>
        <div class="col-xs-12 col-sm-8">
         自定义需要配合先写好对应模板
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-content" data-rule="required" class="form-control" name="row[content]" type="text">
        </div>
		
		
			<div  style="    width: fit-content;
    margin: 0px auto;" >
    <script id="editor" type="text/plain" style="width:869px;height:300px;"></script>
	</div>
    </div>
    <div class="form-group"  style="display:none">
        <label class="control-label col-xs-12 col-sm-2">{:__('Is_read')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-is_read" data-rule="required" class="form-control selectpicker" name="row[is_read]">
               
                    <option value="0" selected>未读</option>
             
            </select>

        </div>
    </div>
    <div class="form-group myhidden" >
        <label class="control-label col-xs-12 col-sm-2">{:__('Date_add')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-date_add" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[date_add]" type="text" value="{:date('Y-m-d H:i:s')}">
        </div>
    </div>
	
    <div class="form-group layer-footer"  style="
    display: block!important;
" >
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed ">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script type="text/javascript">
$("form").submit(function(e){
$('#c-content').val(UE.getEditor('editor').getContent());

if($('#c-type').val() == 'preson'){

	if($('#c-id_customer').val() =='无' ||  $('#c-id_customer').val() ==''){
	
	e.preventDefault();
		alert('当前通知对象为个人,必须指定客户id');
	 
	}
}



if($('#c-msg_type') == ''){


	e.preventDefault();
		alert('消息类型不可为空');

}


if($('#c-title') == ''){


	e.preventDefault();
		alert('消息标题不可为空');

}

if($('#c-content') == ''){


	e.preventDefault();
		alert('消息内容不可为空');

}



 //e.preventDefault();

  
});
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


    function getContent() {

        alert('当前输入内容为：'+ UE.getEditor('editor').getContent());
    }
   



</script>